package com.labreeze.spring.ioc;

import java.lang.reflect.Field;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

import com.labreeze.spring.pojo.Student;
import com.labreeze.spring.pojo.User;

public class TestBeanFactory {

	public static void main(String[] args) {
		
		ResourcePatternResolver resResolver=new PathMatchingResourcePatternResolver();
		Resource res=resResolver.getResource("classpath:applicationContext.xml");
		
		BeanFactory bf=new XmlBeanFactory(res);
		User user=(User)bf.getBean("user");
		System.out.println(user.getUname());
		
		
		//从此处可以看出beanFactory刚刚开始的时候没有初始化User
		Student stu=(Student)bf.getBean("student");
		System.out.println(stu.getUser().getUname());
		
		
	}
	
}
